home *** CD-ROM | disk | FTP | other *** search
- { Turbo Pascal removable window system }
- { Copyright 1984 Michael A. Covington }
- { PC Tech Journal - Vol 3, #2. February 1985, Pg.121 }
-
- { Modifications by David J. Smith, February, 1985 }
-
- { Requirements: IBM PC or close compatible. Screen }
- { must be in text mode, on page 1, either mono or }
- { color card. }
-
- { NOTE - Call INITWIN before calling MKWIN or RMWIN. }
-
-
- Const
- _Maxwin = 4; { Maximum number of window open at once }
-
- type
- _imagetype = array [1..4096] of char;
- _windimtype = record
- x1, y1, x2, y2: integer
- end; {windimtype}
-
- var
- _win: { Global variable package }
- record
- dim: _windimtype; {current window dimensions }
- depth: integer;
- stack: array[1.._maxwin] of
- record
- image: _imagetype; {Saved screen image }
- dim: _windimtype; {Saved window dimensions}
- x, y: integer {Saved cursor position }
- end
- end;
- _crtmode: byte absolute $0040:$0049;
- _crtwidth: byte absolute $0040:$004A;
- _monobuffer: _imagetype absolute $B000:$0000;
- _colorbuffer: _imagetype absolute $B800:$0000;
-
-
- procedure initwin;
- { Records initial window dimensions }
-
- begin
- with _win.dim do
- begin x1:=1; y1:=1; x2:=_crtwidth; y2:=25
- end;
- _win.depth:=0
- end; {initwin}
-
-
- procedure boxwin(x1, y1, x2, y2: integer);
- { Draws a box, fills it with blanks, and makes it the current window. }
- { Dimensions geven are for the box; actual window is one unit }
- { smaller in each direction. This routine can be used separately }
- { from the rest of the removeable window package. }
-
- var
- loop: integer;
-
- begin
- window(1,1,80,25);
-
- { Top }
- gotoxy(x1, y1);
- write(chr(213));
- for loop:=x1+1 to x2-1 do write(chr(205));
- write(chr(184));
-
- { Sides }
- For loop:=y1+1 to y2-1 do
- begin
- gotoxy(x1,loop);
- write(chr(179));
- gotoxy(x2,loop);
- write(chr(179));
- end;
-
- { Bottom }
- gotoxy(x1, y2);
- write(chr(212));
- for loop:=x1+1 to x2-1 do write(chr(205));
- write (chr(190));
-
- { Make it the current window }
- window(x1+1, y1+1, x2-1, y2-1);
- clrscr;
- gotoxy(1, 1)
- end; {Boxwin}
-
-
- procedure mkwin(x1, y1, x2, y2: integer);
- { Create a removeable window }
-
- begin
- { Increment stack pointer }
- with _win do depth:=depth+1;
- if _win.depth>_maxwin then
- begin
- writeln(^G,'Windows nested too deep ');
- halt
- end;
-
- { Save contents of screen }
- if _crtmode = 7 then
- _win.stack[_win.depth].image := _monobuffer
- else
- _win.stack[_win.depth].image := _colorbuffer;
-
- _win.stack[_win.depth].dim := _win.dim;
- _win.stack[_win.depth].x := wherex;
- _win.stack[_win.depth].y := wherey;
-
- { Create window }
- boxwin(x1,y1,x2,y2);
- _win.dim.x1 := x1+1;
- _win.dim.y1 := y1+1; { Allow for margins }
- _win.dim.x2 := x2-1;
- _win.dim.y2 := y2-1;
- end; {mkwin}
-
-
- procedure rmwin;
- { Remove the most recently created removable window }
- { Restore the screen contents, window dimensions, }
- { and position of the cursor. }
-
- begin
- if _win.depth > 0 then
- with _win do
- begin
- if _crtmode = 7 then
- _monobuffer := stack[depth].image
- else
- _colorbuffer := stack[depth].image;
- dim := stack[depth].dim;
- window(dim.x1,dim.y1,dim.x2,dim.y2);
- gotoxy(stack[depth].x,stack[depth].y);
- depth := depth - 1
- end {with}
- else
- writeln(^g' No More Windows to remove ')
- end; {rmwin}
-
-
-
-
- {EOF}